package com.example.dog.core.threads.quartz.config;

import com.example.dog.core.threads.quartz.task.ReturnTierdTask;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ReturnTierdConfig {
    @Bean
    public JobDetail teatQuartzDetail(){
        return JobBuilder.newJob(ReturnTierdTask.class).withIdentity("returnTierdTask").storeDurably().build();
    }

    @Bean
    public Trigger testQuartzTrigger(){
        SimpleScheduleBuilder scheduleBuilder = SimpleScheduleBuilder.simpleSchedule()
                .withIntervalInSeconds(60)  //设置时间周期单位秒
                .repeatForever();
        return TriggerBuilder.newTrigger().forJob(teatQuartzDetail())
                .withIdentity("returnTierdTask")
                .withSchedule(scheduleBuilder)
                .build();
    }
}
